﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SeaBattle.Domain.Entities
{
    public class Ship
    {
        private List<ShipPart> parts = new List<ShipPart>();

        public Ship(int x, int y, byte partsCount)
        {
            InitializeShip(x, y, partsCount);
        }

        public int Id { get; set; }
        public int X { get; private set; }
        public int Y { get; private set; }
        public bool LayOut { get; set; }

        private void InitializeShip(int x, int y, byte partsCount)
        {
            X = x;
            Y = y;
            for (byte i = 0; i < partsCount; i++)
            {
                parts.Add(new ShipPart(this));
            }
        }

        public IList<ShipPart> Parts { get { return parts.AsReadOnly(); } }

        public int PartsCount { get { return parts.Count; } }
    }
}
